package com.bops.biz.permission;

import java.util.List;

/**
 * @author 轰天雷 2012-5-31 上午09:39:11
 */
public class RoleGroup {

    private boolean    enabled;
    private String     name;
    private List<Role> roles;

    /**
     * @return the enabled
     */
    public boolean isEnabled() {
        return enabled;
    }

    /**
     * @param enabled the enabled to set
     */
    public void setEnabled(boolean enabled) {
        this.enabled = enabled;
    }

    /**
     * @return the name
     */
    public String getName() {
        return name;
    }

    /**
     * @param name the name to set
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * @return the roles
     */
    public List<Role> getRoles() {
        return roles;
    }

    /**
     * @param roles the roles to set
     */
    public void setRoles(List<Role> roles) {
        this.roles = roles;
    }

    /**
     * 这个组有没有某个权限
     * 
     * @param roleName
     * @return
     */
    public boolean hasRole(String roleName) {
        if (roles == null || roles.isEmpty() || roleName == null) {
            return false;
        }
        for (Role role : roles) {
            if (roleName.equals(role.getName())) {
                return true;
            }
        }
        return false;
    }

}
